function getMonthsBetween(startDate, endDate) {
    var months = [];
    var current = new Date(startDate);
    while (current <= endDate) {
        months.push(new Date(current));
        current.setMonth(current.getMonth() + 1);
    }
    return months;
}
// 示例使用：
var start = new Date('2023-01-01');
var end = new Date('2023-04-01');
var months = getMonthsBetween(start, end);
months.forEach(function (month) { return console.log(month.toISOString().substring(0, 7)); });
